package com.insight.config;

import io.minio.MinioClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * T093: MinIO对象存储配置
 * 配置MinioClient连接
 *
 * @author Insight Team
 */
@Slf4j
@Configuration
public class MinIOConfig {

    @Value("${minio.endpoint}")
    private String endpoint;

    @Value("${minio.access-key}")
    private String accessKey;

    @Value("${minio.secret-key}")
    private String secretKey;

    @Value("${minio.connect-timeout:5000}")
    private long connectTimeout;

    @Value("${minio.write-timeout:30000}")
    private long writeTimeout;

    @Value("${minio.read-timeout:30000}")
    private long readTimeout;

    /**
     * 创建MinioClient Bean
     *
     * @return MinioClient实例
     */
    @Bean
    public MinioClient minioClient() {
        log.info("初始化MinIO客户端: endpoint={}", endpoint);

        return MinioClient.builder()
                .endpoint(endpoint)
                .credentials(accessKey, secretKey)
                .build();
    }
}
